package com.mashibing.vector;

public class Array_Square {
    public int[] array_Square(int arr[]){
        int [] ret = new int[arr.length];
        int k=arr.length-1;
        for(int i=0,j=arr.length-1;i<=j;){
            if(arr[i]*arr[i]>arr[j]*arr[j]){
                ret[k--]=arr[i]*arr[i];
                i++;
            }
            else{
                ret[k--]=arr[j]*arr[j];
                j--;
            }
        }
        return ret;
    }
}
